<?php
/*
	插件概览
*/
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
if($_RQ['op']=='edit'){
	$type=intval($_RQ['type']);
	if(!$type){
		$typetitle='箱标入库';
	}elseif($type==6){
		$typetitle='盒标入库';
	}elseif($type==1){
		$typetitle='箱标出库';
	}elseif($type==10){
		$typetitle='盒标出库';
	}elseif($type==3){
		$typetitle='箱标退货';
	}elseif($type==30){
		$typetitle='盒标退货';
	}
	$return['typetitle']=$typetitle;
	$item=array(
		'type'=>$type,
		'codes'=>array(),
		'merchid'=>'0',
		'storeid'=>$this->store_id,
		'workerid'=>$this->workerid,
	);
	$return['item']=$item;
	$return['worker']=$worker;
	$return['merchs']=pdo_getall('jy_merch_user',array('status'=>1,'uniacid'=>$_SESSION['uniacid']),array('id','merchname'));
	$return['merchs'][]=array('id'=>'0','merchname'=>'请选择代理商');
	exi($return);
}
if($_RQ['op']=='getmerchs'){
	$tomerchname=$_RQ['tomerchname'];
	$return['merchs']=pdo_getall('jy_merch_user',array('status'=>1,'uniacid'=>$_SESSION['uniacid'],'merchname like'=>'%'.$tomerchname.'%'),array('id','merchname'));
	$return['merchid']=$return['merchs'][0]['id'].'';
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(($postdata['type']==1 || $postdata['type']==10) &&!$postdata['merchid']){
		exi('请选择代理商！','error');
	}
	if(!$postdata['codes']){
		exi('请扫标签！','error');
	}
	$this->model('store')->upkulog($postdata);
	//商家直接入库
	if($postdata['type']==1 || $postdata['type']==10){
		$postdata['type']=$postdata['type']==1?0:6;
		$this->model('merch')->upkulog($postdata);
	}
	exi('操作成功！','','/store.index/');
}